#include<bits/stdc++.h>
using namespace std;
// 实验要求: 编程计算下列表达式的值: 
// (1) unsigned int 型数据: 1+4294967295=?;1-4294967295=?
// (2) int 型数据: 2147483647+1=?;-2147483648-1=?
// (3) float 型数据: (1.0 + 123456.789e30) + (-123456.789e30) = ?;
// 1.0 + (123456.789e30 + (- 123456.789e30)) = ?
// 要求分别用十进制和十六进制形式显示各种操作的结果。

FILE *fp = fopen("221900175output.out", "w+");

void print(const char *_format, ...) {
    va_list args;
    va_start(args, _format);
    vfprintf(fp, _format, args);
    va_end(args);
}

int main() {
    print("----------------Test1----------------\n");
    unsigned int test1 = UINT32_MAX;
    print("1+4294967295= %12u in 10base, %08x in 16base.\n", 1U + test1, 1U + test1);
    print("1-4294967295= %12u in 10base, %08x in 16base.\n", 1U - test1, 1U - test1);
    print("----------------Test2----------------\n");
    int test2[2];
    test2[0] = INT32_MAX + 1;
    test2[1] = INT32_MIN - 1;
    print("2147483647+1= %12d in 10base, %08x in 16base.\n", test2[0], test2[0]);
    print("-2147483648-1 %12d in 10base, %08x in 16base.\n", test2[1], test2[1]);
    print("----------------Test3----------------\n");
    float test3 = (1.0f + 123456.789e30f) + (-123456.789e30f);
    print("(float)(1.0 + 123456.789e30) + (-123456.789e30) = %f in 10base, %a in 16base.\n", test3, test3);
    print("----------------Test4----------------\n");
    double test4 = (1.0 + 123456.789e30) + (-123456.789e30);
    print("(1.0 + 123456.789e30) + (-123456.789e30) = %f in 10base, %a in 16base.\n", test4, test4);
    fclose(fp);

    // ----------------Test1----------------
    // 1+4294967295=            0 in 10base, 0 in 16base.
    // 1-4294967295=            2 in 10base, 2 in 16base.
    // ----------------Test2----------------
    // 2147483647+1=  -2147483648 in 10base, 80000000 in 16base.
    // -2147483648-1   2147483647 in 10base, 7fffffff in 16base.
    // ----------------Test3----------------
    // (float)(1.0 + 123456.789e30) + (-123456.789e30) = 0.000000 in 10base, 0x0p+0 in 16base.
    // ----------------Test4----------------
    // (1.0 + 123456.789e30) + (-123456.789e30) = 0.000000 in 10base, 0x0p+0 in 16base.

        //system("pause");
    return 0;
}
